package com.zzx.schoolfellow.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.google.gson.Gson;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.Date;

/**
 * @program: schoolfeoolw_backend
 * @description:
 * @author: zzx
 * @create: 2023-03-26 20:50
 **/
@Data
@TableName("chat_message")
public class ChatMessage {
    @TableId(type = IdType.AUTO)
    private Long id;
    private String sender;
    private String receiver;
    private String content;
    private LocalDateTime createTime;
    private Boolean isRead;

    public static ChatMessage fromJson(String json) {
        return new Gson().fromJson(json, ChatMessage.class);
    }

    public String toJson() {
        return new Gson().toJson(this);
    }
}
